package com.world.rickcloudendpoint.stream.filter;

import com.world.rickcloudendpoint.common.exception.FilterException;
import com.world.rickcloudendpoint.stream.filter.Filter;
import com.world.rickcloudendpoint.stream.filter.FilteredMessages;
import com.world.rickcloudendpoint.stream.message.Message;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;

import java.util.List;

/**
 * @description:
 * @author: jlsong
 * @date: 2022/03/11 20:40:36
 * @version: 1.0
 */
@AllArgsConstructor
@Log4j2
public class RickCloudFilter {
    private final Filter filter;

    public FilteredMessages applyFilter(List<Message> messages) throws FilterException {
        // 过滤消息体
        FilteredMessages filteredMessages = filter.filter(messages);
        // 获取无效消息容量
        int filteredMessageCount = filteredMessages.sizeOfInvalidMessages();
        if (filteredMessageCount > 0) {
            // 打印无效消息的相关信息
        }
        return filteredMessages;
    }
}
